import { createBrowserRouter, Navigate } from 'react-router'
import About from '../views/About/About'
import Layout from '../Layout'
// import Home from '../views/Home/Home'
import Contact from '../views/Contact/Contact'
import Parent from '../views/Parent/Parent'
import Control from '../views/Control/Control'
import UnControl from '../views/UnControl/UnControl'
import Memo from '../views/Memo/Memo'
import NewHome from '../views/NewHome'
import ErrorPage from '../views/errorPage'
import Mall from '../views/mall'

const HomeRedirect = () => <Navigate to="/home" replace></Navigate>

const routes = [
  {
    path: '/',
    element: <Layout></Layout>,
    children: [
      {
        path: "",
        element: <HomeRedirect></HomeRedirect>
      },
      {
        path: "/home",
        element: <NewHome></NewHome>
      },
      {
        path: "/about",
        element: <About></About>
      },
      {
        path: "/contact",
        element: <Contact></Contact>
      },
      {
        path: "/parent",
        element: <Parent></Parent>
      },
      {
        path: "/control",
        element: <Control></Control>
      },
      {
        path: "/uncontrol",
        element: <UnControl></UnControl>
      },
      {
        path: "/memo",
        element: <Memo></Memo>
      },
      {
        path: "/mall",
        element: <Mall></Mall>
      }
    ]
  },
  {
    path: "*",
    element: <ErrorPage></ErrorPage>
  }
]

const router = createBrowserRouter(routes)

export default router
